package 剑指offer;

import java.util.LinkedList;

/**
 * @author zhangjunfei
 * @date 2023/7/18 16:00
 */
public class O_09 {


    LinkedList<Integer> A, B;
    public O_09() {
        A = new LinkedList<Integer>();
        B = new LinkedList<Integer>();
    }


    public void appendTail(int value) {
        A.add(value);
    }

    public int deleteHead() {
        if (!B.isEmpty()) {
            return B.removeLast();
        }
        if (A.isEmpty()) {
            return -1;
        }
        while(!A.isEmpty()){
            B.addLast(A.removeLast());
        }
        return B.removeLast();
    }
}
